package lab03;

import org.apache.commons.dbcp.BasicDataSource;

import java.sql.Connection;
import java.sql.SQLException;

public class DBCPDatasource {

    private static BasicDataSource basicDataSource = new BasicDataSource();

    static {
        basicDataSource.setUrl(DB.URL);
        basicDataSource.setUsername(DB.USERNAME);
        basicDataSource.setPassword(DB.PASSWORD);
        // ...
    }

    public static Connection getConnection() {
        try {
            return basicDataSource.getConnection();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}